package com.nulldev.util.networking.npacket4.extensions.security;

import static com.nulldev.util.networking.npacket4.util.nPacketUtil.__readShort;

import java.io.IOException;
import java.io.InputStream;

import com.nulldev.util.networking.npacket4.extensions.PacketExtension;
import com.nulldev.util.networking.npacket4.extensions.PacketExtensions;

public class PacketHashVerificationExtension implements PacketExtension {

	private static final long serialVersionUID = -7119931305159185974L;

	public static enum PacketHashType {
		UNKNOWN(0),
		CRC32(1),
		MURMUR1(2),
		MURMUR2(3),
		MURMUR3(4),
		BCRYPT(5),

		;

		private final short id;

		private PacketHashType(final int id) {
			this.id = (short) id;
		}

		public short getID() {
			return this.id;
		}
	}

	private short id;

	@Override
	public int extensionID() {
		return PacketExtensions.PacketExtensionID.EXT_PACKET_VERIFY;
	}

	@Override
	public byte[] extensionData() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public byte[] processData(final byte[] data) {
		switch (this.id) {

			case 0:
			default:
				return data;
		}
	}

	@Override
	public PacketExtension readExtensionData(final InputStream dis) throws IOException {
		final short id = __readShort(dis);
		this.id = id;
		return this;
	}

}
